
import {
    dateFormat,
    toast
} from '../../../utils/util.js'
import { getEleSignRechargeRecord } from '../../api/contract'
import user from '../../../utils/user'
Page({

    /**
     * 页面的初始数据
     */
    data: {
        data: [],
        insureCompanyType:'',
        productType: '',
        page:1,
        hasNextPage:true
    },
    onLoad (options) {
        this.setData({
            productType:options.type
        })
        this.getEleSignRechargeRecord()
        console.log(options,'options')
    },
    /**
     * 生命周期函数--监听页面显示
     */
    onShow () {},
    rechargeGtg() {
        wx.navigateTo({
            url: '/packageContract/pages/contract-recharge-gtg/contract-recharge-gtg',
        })
    },

    rechargeWechat(){
        // 微保暂不可用
        // if(user.insureCompanyType !== 'insure002_gsc'){
        //     toast('功能维护中')
        //     return
        // }
        toast('功能维护中')
        return
        wx.navigateTo({
            url: '/packageContract/pages/contract-recharge-wechat/contract-recharge-wechat',
        })
    },
    goNext(event) {
        wx.navigateTo({
            url: '/packageInsurance/pages/insurance-gtg-success/insurance-gtg-success?id=' + event.currentTarget.dataset.id + '&type=contract',
        })
    },
    async getEleSignRechargeRecord () {
        // 电子签
        const result = await getEleSignRechargeRecord({
            pageNum:this.data.page,
            pageSize:7
        })
        if(!result.hasNextPage){
            this.setData({
                hasNextPage:false
            })
        }
        const arr = []
        arr.push(...this.data.data)
        arr.push(...result.list)
        console.log(result, 'result调用啦')
        this.setData({
            data:arr
        })
    },
    onReachBottom(){
        console.log('调用；啊')
        if(!this.data.hasNextPage){
            return
        }
        this.setData({
            page: this.data.page += 1
        })
        this.getEleSignRechargeRecord()
    }
})